package com.lonty.intelligence.controller;

import com.lonty.intelligence.api.Result;
import com.lonty.intelligence.api.ResultCode;
import com.lonty.intelligence.service.StreetNotificationService;
import com.lonty.intelligence.vo.StreetNotificationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author 陈璇
 * @Date 2020/6/28 16:42
 * @Version 1.0
 */
@RestController
@RequestMapping("app/streetNotification")
@Validated
@Api(tags = "街道通知接口", produces = "application/json")
public class StreetNotificationController {

    @Resource
    private StreetNotificationService streetNotificationService;

    @ApiOperation(value = "保存街道通知", httpMethod = "POST")
    @PostMapping("saveStreetNotification")
    public Result saveStreetNotification(@ModelAttribute StreetNotificationVo streetNotificationVo){
        if(streetNotificationService.saveStreetNotification(streetNotificationVo)){
            return Result.builder().build();
        }
        return Result.builder(ResultCode.OPERATION_ERROR).build();
    }

    @ApiOperation(value = "根据类型获取通知列表", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型(1:所有人 2:老人 3:年轻人 4:固定人)",dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "userInfoId", value = "接收用户ID",dataType = "string", paramType = "query")
    })
    @GetMapping("getStreetNotification")
    public Result getStreetNotification(Integer type, String userInfoId){
        return Result.builder()
                .data(streetNotificationService.getStreetNotification(type, userInfoId))
                .build();
    }

    @ApiOperation(value = "获取首页轮播图", httpMethod = "GET")
    @GetMapping("getLogoList")
    public Result getLogoList(){
        return Result.builder()
                .data(streetNotificationService.getLogoList())
                .build();
    }

}
